package com.mcxx.modules.base.utils;

import com.mcxx.modules.dictionary.param.DictionarySimpleParam;
import com.mcxx.util.CommonUtil;
import com.yinhai.ta404.module.dict.entity.TaDictPo;

import java.util.List;

public class DictionaryUtil {


    public static String getDictCodeByName(String dicName, List<DictionarySimpleParam> list) {
        String returnStr = null;
        if (!CommonUtil.invalidArgs(dicName)) {
            if (null != list && list.size() > 0) {
                for (DictionarySimpleParam dto : list) {
                    if (dicName.equals(dto.getStandardCode())) {
                        returnStr = dto.getName();
                        break;
                    }
                }
            }
        }

        return returnStr;
    }

    public static TaDictPo getDictBylabel(String lable, List<TaDictPo> list) {
        TaDictPo dictPo = new TaDictPo();
        for (TaDictPo taDictPo : list) {
            if (lable.equals(taDictPo.getLabel())) {
                dictPo = taDictPo;
                break;
            }
        }
        return dictPo;
    }
    public static TaDictPo getDictByValue(String value, List<TaDictPo> list) {
        TaDictPo dictPo = new TaDictPo();
        for (TaDictPo taDictPo : list) {
            if (value.equals(taDictPo.getValue())) {
                dictPo = taDictPo;
                break;
            }
        }
        return dictPo;
    }
}
